class HouseItem:
    def __init__(self,name,area):
        self.name = name
        self.area = area
    def __str__(self):
        return f"家具名字{self.name}，占地面积{self.area}平米"

class House:
    def __init__(self,name,area):
        self.name = name
        self.total_area = area
        self.free_area = area
        self.item_list = []

    def __str__(self):
        return (f"户型{self.name},总面积:{self.total_area}平米，剩余面积:{self.free_area}平米，"
                f"家具名称列表{self.item_list}")
    def add_item(self,item):
        if self.free_area > item.area:
            self.item_list.append(item.name)
            self.free_area -= item.area
            print(f"{item.name}添加成功")
        else:
            print("剩余面积不足，换个大房子试试吧")

# 创建家具对象
bed = HouseItem("席梦思",4)
chest = HouseItem("衣柜",2)
table = HouseItem("餐桌",1.5)
print(bed)
print(chest)
print(table)

# 创建房子对象
house= House("三室一厅",150)
print(house)
house.add_item(bed)
print(house)